home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / disk_tools / cd32tools / cd32ctrl.c < prev    next >
C/C++ Source or Header  |  1995-07-12  |  3KB  |  147 lines

  1. /*
  2.     CD³²Ctrl Version 1.1, quick update
  3.     
  4.     changes:
  5.     
  6.     - SPEED now works not only on my drive
  7.     - STOP stops the drive immediatly (some kind of NoiseSaver... ;-)
  8.     
  9.     i don't know what's the difference between EJECTRESET and CDREBOOT,
  10.     but i found both functions and why not jump in...?
  11.     
  12.     all warning strings are disabled to save space. i use all this
  13.     commands in a 10K RAD: drive - and i know how to use them.
  14.     reenable them if you like.
  15. */
  16.  
  17. //int main (void);
  18. //int _main (void) { return main(); }
  19.  
  20. #include <exec/exec.h>
  21. #include <dos/dos.h>
  22. #include <libraries/lowlevel.h>
  23. #include <devices/cd.h>
  24. #include <proto/exec.h>
  25. #include <proto/dos.h>
  26. #include <proto/lowlevel.h>
  27.  
  28. #define TEMPLATE "REQ/S,NOREQ/S,CDREBOOT/S,NOCDREBOOT/S,EJECTRESET/S,NOEJECTRESET/S,DOUBLESPEED/S,SINGLESPEED/S,QUIET/S,STOP/S"
  29.  
  30. struct abc {
  31.     ULONG    req,noreq,res,nores,eject,noeject,dspeed,sspeed;
  32.     ULONG    quiet,stop;
  33. //    ULONG    pads[8]; /* someone said RDArgs must be sized to a 16-longs boundary ??? */
  34. } args = {0};
  35.  
  36. ULONG Cfg2Speed[] =
  37. {
  38.     TAGCD_READSPEED, 150,
  39.     TAGCD_READXLSPEED, 150,
  40.     TAGCD_PLAYSPEED, 150,
  41.     TAG_END, 0
  42. };
  43.  
  44. ULONG Cfg1Speed[] =
  45. {
  46.     TAGCD_READSPEED, 75,
  47.     TAGCD_READXLSPEED, 75,
  48.     TAGCD_PLAYSPEED, 75,
  49.     TAG_END, 0
  50. };
  51.  
  52. ULONG CfgEject[] =
  53. {
  54.     TAGCD_EJECTRESET, FALSE,
  55.     TAG_END, 0
  56. };
  57.  
  58. int main (void)
  59. {
  60.     struct RDArgs *rdargs;
  61. //    struct abc args = {0};
  62.     struct MsgPort *mp;
  63.     struct IOStdReq *ior;
  64. //    struct DosLibrary *DOSBase;
  65. //    struct ExecBase *SysBase = (struct ExecBase*)*(ULONG*)4;
  66. //    struct Library *LowLevelBase;
  67.  
  68. //    DOSBase = (struct DosLibrary*)OpenLibrary("dos.library",39);
  69. //    LowLevelBase = OpenLibrary("lowlevel.library",39);
  70.     
  71.     if (rdargs=ReadArgs(TEMPLATE,(LONG*)&(args),NULL))
  72.     {
  73.     //    if(!args.quiet)
  74.     //        PutStr("*** CD³²Ctrl Version 1.0.0 *** by Daniel Balster\n");
  75.  
  76.         if(mp=CreateMsgPort())
  77.         {
  78.             if(ior=(struct IOStdReq*)CreateIORequest(mp,sizeof(struct IOStdReq)))
  79.             {
  80.                 if(!OpenDevice("cd.device",0,ior,0))
  81.                 {
  82.                     /* ok, the following is somehow ugly - but who carez */
  83.                 
  84.                     ior->io_Command    = CD_CONFIG;
  85.                     ior->io_Length    = 0;
  86.  
  87.                     if (args.eject)
  88.                     {
  89.                         CfgEject[1]    = TRUE;
  90.                         ior->io_Data    = (APTR) &CfgEject;
  91.                         DoIO(ior);
  92.                     }
  93.  
  94.                     if (args.noeject)
  95.                     {
  96.                         CfgEject[1]    = FALSE;
  97.                         ior->io_Data    = (APTR) &CfgEject;
  98.                         DoIO(ior);
  99.                     }
  100.  
  101.                     if (args.dspeed)
  102.                     {
  103.                         ior->io_Data    = (APTR) &Cfg2Speed;
  104.                         DoIO(ior);
  105.                     }
  106.                     
  107.                     if (args.sspeed)
  108.                     {
  109.                         ior->io_Data    = (APTR) &Cfg1Speed;
  110.                         DoIO(ior);
  111.                     }
  112.  
  113.                     if (args.stop)
  114.                     {
  115.                         ior->io_Command = CD_MOTOR;
  116.                         ior->io_Length    = 0;
  117.                         DoIO(ior);
  118.                     }
  119.                 
  120.                     CloseDevice((struct IORequest*)ior);
  121.                 }
  122.     //            else PutStr("cannot access cd.device?\n");
  123.                 
  124.                 DeleteIORequest((struct IORequest*)ior);
  125.             }
  126.     //        else PutStr("cannot create ioreq?\n");
  127.  
  128.             DeleteMsgPort(mp);
  129.         }
  130.     //    else PutStr("cannot create msgport?\n");
  131.  
  132.  
  133.         if (args.req) SystemControl(SCON_KillReq,FALSE,TAG_END);
  134.         if (args.noreq) SystemControl(SCON_KillReq,TRUE,TAG_END);
  135.         if (args.res) SystemControl(SCON_CDReboot,CDReboot_On,TAG_END);
  136.         if (args.nores) SystemControl(SCON_CDReboot,CDReboot_Off,TAG_END);
  137.  
  138.         FreeArgs(rdargs);
  139.     }
  140. //    else PrintFault(IoErr(),0);
  141.  
  142.  
  143. //    CloseLibrary(DOSBase);
  144. //    CloseLibrary(LowLevelBase);
  145.     return RETURN_OK;
  146. }
  147.